package tm.gui;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 * Form bean for a Struts application.
 * Users may access 2 fields on this form:
 * <ul>
 * <li>userName - [your comment here]
 * <li>userPassword - [your comment here]
 * </ul>
 * @version 	1.0
 * @author
 */
public class UserData extends ActionForm

{

    private int userId;

    private String userPassword = null;

    /**
     * Get userName
     * @return String
     */
    public int getUserId() {
	return userId;
    }

    /**
     * Set userName
     * @param <code>String</code>
     */
    public void setUserId(int id) {
	this.userId = id;
    }

    /**
     * Get userPassword
     * @return String
     */
    public String getUserPassword() {
	return userPassword;
    }

    /**
     * Set userPassword
     * @param <code>String</code>
     */
    public void setUserPassword(String u) {
	this.userPassword = u;
    }

    public void reset(ActionMapping mapping, HttpServletRequest request) {

	// Reset values are provided as samples only. Change as appropriate.

    	userId = 0;
	userPassword = null;

    }

    public ActionErrors validate(ActionMapping mapping,
	    HttpServletRequest request) {

	ActionErrors errors = new ActionErrors();
	// Validate the fields in your form, adding
	// adding each error to this.errors as found, e.g.

	 if (userId == 0) {
	   errors.add("userId", new ActionMessage("userId-required"));
	 }
	
	return errors;

    }
}
